package com.turing.data.scripts.contract.transfer

import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO


/**
 * 场景：资产管理合同
 * 版本：Version 1.0
 * 要素名称：管理费
 */

class ManagementCosts_30199_10_transfer {

    static List< TaskElementVO.DrawResultVO > doConvert(List< TaskElementVO.DrawResultVO > resultVOs, DependParamsVO dependParams){

        def regex = /管理费.*为(\d+.\d+)%/

        if (resultVOs!=null && resultVOs.size()>0){
            for (int i = 0; i < resultVOs.size(); i++) {
                String modelValue = resultVOs.get(i).getText()
//                Log.info("ManagementCosts_13308_1101_transfer_modelValue={}",modelValue)
                if (modelValue != null && !modelValue.equals("")) {
                    if(modelValue.contains("【") && modelValue.contains("】") ){
                        int startIndex = modelValue.indexOf("【") + 1
                        int endIndex = modelValue.indexOf("】")
                        String value = modelValue.substring(startIndex , endIndex)
//                        value = value + "%"
                        resultVOs.get(i).setBusinessValue(value)
                        resultVOs.get(i).setType(1)
//                        continue
                    }
                    else if(modelValue.contains("【") && !modelValue.contains("】") ){
                        int startIndex = modelValue.indexOf("【") + 1
                        int endIndex = modelValue.length()
                        String value = modelValue.substring(startIndex , endIndex)
//                        value = value + "%"
                        resultVOs.get(i).setBusinessValue(value)
                        resultVOs.get(i).setType(1)
//                        continue
                    }
                    else if(modelValue =~ regex){
                        def value = ( modelValue =~ regex )
                        resultVOs.get(i).setBusinessValue(value[0])
                        resultVOs.get(i).setType(1)
                    }
                    else{
                        resultVOs.get(i).setBusinessValue(modelValue)
                        resultVOs.get(i).setType(1)
                    }

                }

            }
        }

        return resultVOs
    }

}
